﻿using CrystalDecisions.CrystalReports.Engine;
using gfLibrary;
using IYAKASAPortal.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IYAKASAPortal.PrintAll
{
    public partial class PrintPF_X_JZJS : System.Web.UI.Page
    {
        private UserInfo userInfo { get; set; }
        private ReportDocument document;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] != null && Session["UserName"].ToString() != "")
            {
                string userName = Session["UserName"].ToString();
                userInfo = IYAKASAPortal.Services.UserAuthority.GetUserAuthority(userName);
            }
            else
            {
                gfJs.RunFunction(this.Page, "parent.window.location = '../logout.aspx';");
            }

            if (Request["UniqueKey"] != null && Request["UniqueKey"].ToString() != "")
            {
                BindReportData(Request["UniqueKey"].ToString());
            }
            else
            {
                gfJs.RunFunction(this.Page, "parent.window.location = '../logout.aspx';");
            }
        }

        private void BindReportData(string strKey)
        {
            //string strPath = Server.MapPath("~/rpt/CrystalReportPF_X4_BTG.rpt");//国标
            string strPath = Server.MapPath("~/rpt/CrystalReport_SC_BTG.rpt");//四川省
            SetHBDateSource setData = new SetHBDateSource();

            document = setData.BindPF_X4_BTG_ReportEx(strKey, strPath);
            CRBTG.ReportSource = document;
            CRBTG.DataBind();
            CRBTG.RefreshReport();
        }

        protected override void OnUnload(EventArgs e)
        {
            document.Dispose();
            base.OnUnload(e);
        }
    }
}